package com.sadam.ui4.FragmentPlusPage;//package com.sadam.ui4.FragmentPlusPage;
//
//import android.content.Context;
//import android.hardware.Camera;
//import android.view.SurfaceHolder;
//import android.view.SurfaceView;
//
//import java.io.IOException;
//
//public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
//    private SurfaceHolder surfaceHolder;
//    private Camera camera;
//
//    public CameraPreview(Context context, Camera camera) {
//        super(context);
//        this.camera = camera;
//        surfaceHolder = getHolder();
//        surfaceHolder.addCallback(this);
//        surfaceHolder.setType(surfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//    }
//
//    @Override
//    public void surfaceCreated(SurfaceHolder holder) {
//        try {
//            holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//            holder.setKeepScreenOn(true);
//            camera.setPreviewDisplay(holder);
//            camera.setDisplayOrientation(90);
//            camera.startPreview();
//        } catch (IOException ioException) {
//            ioException.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Override
//    public void surfaceDestroyed(SurfaceHolder holder) {
//
//    }
//
//    @Override
//    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
//        if (surfaceHolder.getSurface() == null) {
//            return;
//        }
//        try {
//            camera.stopPreview();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        try {
//            this.surfaceCreated(holder);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//}